package com.ruoyi.web.controller.mxerp;


import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.service.VMxWareOutService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.VMxWareOut;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * VIEWController
 *
 * @author yushuaixm
 * @date 2024-08-21
 */
@RestController
@RequestMapping("/mxerp/wareout")
public class VMxWareOutController extends BaseController {
    @Autowired
    private VMxWareOutService vMxWareOutService;

    /**
     * 查询VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('mxerp:wareout:list')")
    @GetMapping("/list")
    public TableDataInfo list(VMxWareOut vMxWareOut) {
        startPage();
        List<VMxWareOut> list = vMxWareOutService.selectVMxWareOutList(vMxWareOut);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('mxerp:wareout:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VMxWareOut vMxWareOut) {
        List<VMxWareOut> list = vMxWareOutService.selectVMxWareOutList(vMxWareOut);
        ExcelUtil<VMxWareOut> util = new ExcelUtil<VMxWareOut>(VMxWareOut.class);
        util.exportExcel(response, list, "VIEW数据");
    }

    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('mxerp:wareout:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(vMxWareOutService.selectVMxWareOutById(id));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('mxerp:wareout:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VMxWareOut vMxWareOut) {
        return toAjax(vMxWareOutService.insertVMxWareOut(vMxWareOut));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('mxerp:wareout:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VMxWareOut vMxWareOut) {
        return toAjax(vMxWareOutService.updateVMxWareOut(vMxWareOut));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('mxerp:wareout:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(vMxWareOutService.deleteVMxWareOutByIds(ids));
    }
}
